/*
 *  mmu.h
 *  
 *
 *  Created by Rayvionne French on 7/2/11.
 *  Copyright 2011 __MyCompanyName__. All rights reserved.
 *
 */

#ifndef MMU_H
#define MMU_H

#include "machine.h"
#include "vmtranslate.h"
#include "list.h"

// The following class defines an entry in a translation table -- either
// in a page table or a TLB.  Each entry defines a mapping from one 
// virtual page to one physical page.
// In addition, there are some extra bits for access control (valid and 
// read-only) and some bits for usage information (use and dirty).
class VMTranslationEntry;
class MMU{
  public:
	MMU(Machine* systemMachine);
	~MMU();
	void iptSetEntry(VMTranslationEntry* from);
	VMTranslationEntry* iptGetEntry(int index);
	int iptFind(int vpn, int processID); // return physical page number or -1 if not found
	void iptClearPage(int ppn, int processID);
	void iptClearAt(int index, int processID);
	void iptClearProcess(int processID);
	int iptGetNumEntries() {return iptEntries;}
	void iptSetDirty(int ppn, bool dirty);
	VMTranslationEntry* iptGetEviction();
	
	private:
	VMTranslationEntry* ipt;
	Machine* machine;	
	int iptEntries;
	List *pageQueue;
};

#endif
